home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / nywmap.arc / KEYTABLE.DOC < prev    next >
Encoding:
Text File  |  1986-11-11  |  7.1 KB  |  173 lines

  1.                         REMAPPING THE KEYBOARD
  2.  
  3.     A  character  that  you  type at the keyboard can take on 256 dif-
  4. ferent values, from 0 to 255. On the IBM PC, the ASCII characters  are
  5. numbered  from  0 to 127, and the IBM extended characters are numbered
  6. from 128 to 255. All of the  function  key  combinations  and  numeric
  7. keypad combinations fall into the extended character set. 
  8.  
  9.     The  editor  has  an internal table which is used to translate one
  10. value into another. This internal table is 256 bytes long, with byte 0
  11. holding the translation value for keystroke value 0,  byte  1  holding
  12. the  value for keystroke 1, etc. The default values for this table in-
  13. dicate no translations (ie keystroke number n is translated into value
  14. n.) 
  15.  
  16.  
  17.                        AN EXAMPLE OF REMAPPING
  18.  
  19.     As an example where translation may be desirable, let's consider a
  20. very simple remapping of the keyboard. The command that is  associated
  21. with  the  F1  function key is <DELETE LINE>. Let's say that you would
  22. like the <HELP> function to be assigned to the F1 key, and the <DELETE
  23. LINE> function assigned to the <ALT>  D  key.  Currently,  the  <HELP>
  24. function is assigned to the <ALT> H key. 
  25.  
  26.     To  find  out  what  keystroke  values the F1, <ALT> D and <ALT> H
  27. keys   produce,   use   the  <TEST  KEYS>  command  from  the  editor.
  28. This command is done by pressing the ALT F10 key. The <TEST KEYS> com-
  29. mand prompts you for a keystroke, and then prints the value  that  the
  30. keystroke produced. 
  31.  
  32.     After invoking the <TEST KEYS> command, we find that the following
  33. values are produced :
  34.  
  35.   F1     187
  36.   ALT D   60
  37.   ALT H  163
  38.  
  39.     What we would like to do is have the F1 key "generate" the <ALT> H
  40. keystroke,  and have the <ALT> D key "generate" the F1 value. In other
  41. words, we would like to fool the editor into thinking that when the F1
  42. key is pressed, the <ALT> H key was really pressed.
  43.  
  44.     To effect these changes, we would like to put the value  163  into
  45. byte  187  of the table, and put value 187 into byte 160 of the table.
  46. How can we do this without  going  altering  the  editor's  executable
  47. file?
  48.  
  49.  
  50.                           THE KEYTABLE FILE
  51.  
  52.     The  file  which  holds the keystroke translation values is called
  53. "KEYTABLE.NYW". When the editor starts up, it will first look  in your
  54. current subdirectory  for the KEYTABLE.NYW file. If the editor doesn't
  55. find it there, then the editor will search the directories  listed  in
  56. your  DOS  search  path.  If this file still isn't found, then the in-
  57. ternal  table  is  filled  sequentially with the values 0 through 255.
  58. This means that no remapping will be performed.
  59.  
  60.     The KEYTABLE.NYW file contains one or more tables  which  are  256
  61. bytes long, with byte i corresponding to keystroke i. The editor comes
  62. with a default KEYTABLE.NYW file. It also comes with several utilities
  63. to create and alter the KEYTABLE.NYW file. 
  64.  
  65.     The  first  utility we will talk about is called KEYCOMP.EXE. This
  66. program  reads  a  keystroke  configuration  file  and   generates   a
  67. KEYTABLE.NYW file  from  it. A keystroke configuration file contains a
  68. list of keystrokes and their corresponding values. 
  69.  
  70.     Each line of the keystroke configuration file has the form :
  71.  
  72.   key=func
  73.  
  74.     The  "key"  can  be  a  decimal number, a single character between
  75. single quotes, ^char (a control character between 0 and 31), F#  where
  76. '#'  is a number between 1 and 10 (this is a normal function key), AF#
  77. (ALT function key), SF# (SHIFT function key), CF# (CTRL function key),
  78. or @char (ALT character key).
  79.  
  80.     "Func" is a number representing the value that the key produces.
  81.  
  82.     Here are some examples :
  83.  
  84.   120=122   (the key with the value 120 produces 122)
  85.   '#'=289   (a pound sign produces 289)
  86.   ^C=14     (CTRL C produces 14)
  87.   F1=160    (F1 produces 160)
  88.   @A=198    (ALT A produces 198)
  89.   SF9=130   (SHIFT f9 produces 130)
  90.  
  91.     Any keystrokes which aren't mentioned in  the  configuration  file
  92. will just be translated into themselves.
  93.  
  94.     To run the keystroke compiler, type the command
  95.  
  96.     KEYCOMP filename
  97.  
  98. where filename is the name of the  keystroke  configuration  file.  If
  99. everything  goes  well, the KEYTABLE.NYW file will be created. You can
  100. not TYPE out the KEYTABLE.NYW file  since  it  contains  binary  data.
  101. However,  you  can examine it with various disk utilities (such as the
  102. NORTON Utilities). 
  103.  
  104.     The second utility is called KEYCONF.EXE. This program generates a
  105. default keystroke configuration file.  There  are  256  lines  in  the
  106. generated file. The file looks like this : 
  107.  
  108. 0=0
  109. 1=1
  110. ...
  111. 255=255
  112.  
  113.     The  output  from  this  program is written to the screen. You can
  114. redirect the output to a file be giving the command :
  115.     
  116.     KEYCONF > keyfile (or any other name)
  117.  
  118.     Once  this  sample  keystroke configuration file is generated, you
  119. can alter  it  with  any  text  editor,  and  then  compile  it  using
  120. KEYCOMP.EXE. 
  121.  
  122.     The third utility is called KEYTEST.EXE. This  program  waits  for
  123. you  to  type  a  keystroke,  and  then  prints  out the value of that
  124. keystroke. Hitting the <ESC> key will stop the program.  This  program
  125. is also simulated by the <TEST KEYS> command of the editor. 
  126.  
  127.  
  128.                                PREFIXES
  129.  
  130.     Some  people  would like to have the editor emulate their favorite
  131. word processor, and hence, will make key maps which map  the  function
  132. keys  of  the  editor  into  the  keystrokes that their word processor
  133. requires.  Some  word  processors  use  a  two-keystroke  sequence  to
  134. generate  a  command.  One  of the most well-known examples of this is
  135. WordStar (WordStar is a trademark of MicroPro Inc.). For instance, the
  136. keystroke sequence CTRL K D is used to exit WordStar.
  137.  
  138.     You can specify prefixes in the keystroke redefinition file  which
  139. is compiled by the KEYCOMP.EXE program. A prefix line is of the form :
  140.  
  141.   PREFIX <keystroke>
  142.  
  143.     The  PREFIX  statement creates a 256 byte table which contains the
  144. commands generated by the second key of the sequence. As  an  example,
  145. you  press  CTRL  D  right  now to exit the editor. CTRL D generates a
  146. keystroke value of 4. If you would like to use the CTRL K D  keystroke
  147. combination  to  exit  the  editor  instead,  then your keystroke file
  148. should contain a line like this :
  149.  
  150.   PREFIX ^K
  151.   .....        list of CTRL K commands
  152.   D=4
  153.   ......
  154.  
  155.  
  156.     A prefix command table ends when the compiler  encounters  another
  157. PREFIX  statement,  or  when  the  compiler  reaches  the  end  of the
  158. redefinition file. 
  159.  
  160.     All of the prefix definitions should come  after  the  definitions
  161. for  the main table. For a good example, examine the WSKEYS file which
  162. comes with the keyboard remapping facility.  This  file  contains  the
  163. keystroke definitions to configure the keyboard like WordStar.
  164.  
  165.  
  166.                              SOURCE FILES
  167.  
  168.     Included  in  the editor package are the source files to the above
  169. mentioned utilities. We request that if you improve  these  utilities,
  170. that  you  send the source back to us so that we can incorporate it in
  171. future releases. In exchange, you will receive a free copy of the next
  172. release of the editor.
  173.